package com.example.lockfulldemo.service.impl;


import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.lockfulldemo.entity.TicketEntity;
import com.example.lockfulldemo.mapper.TicketMapper;
import com.example.lockfulldemo.service.ITicketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 
 *
 * @author Administrator
 * @date 2022-10-26 09:50:56
 */
@Slf4j
@Service
public class TicketServiceImpl extends ServiceImpl<TicketMapper, TicketEntity> implements ITicketService {
    @Resource
    private TicketMapper ticketMapper;

    @Override
    @Transactional
    public void queryOne(){
        ticketMapper.selectList(null);
        int i = 1/0;
    }

    @Override
    @Transactional(rollbackFor = Throwable.class)
    public void updateTest() {
        ticketMapper.update(null,new LambdaUpdateWrapper<TicketEntity>().set(TicketEntity::getNum,4)
                .eq(TicketEntity::getId,1));
        throw new RuntimeException("Error occurred, rolling back.");
    }


}
